package com.vtb.servlet;

import java.io.IOException;
import java.net.URLEncoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vtb.base.VtbBaseServlet;
import com.vtb.entity.Config;

/**
 *  生成获取Code的链接地址
 *  转发至URL
 * @author tacheno
 */
@SuppressWarnings("serial")
public class RrConnServlet extends VtbBaseServlet {
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		 String redirectUri=URLEncoder.encode(Config.RR_REDIRECT_URL+"/RrOauthServlet", "UTF-8");
		 StringBuffer params=new StringBuffer();
		 params.append("x_renew=").append("true");
	     params.append("&").append("client_id=").append(Config.RR_APP_KEY);
         params.append("&").append("response_type=").append("code");
         params.append("&").append("redirect_uri=").append(redirectUri);
         params.append("&").append("display=").append("page");
         params.append("&").append("scope=").append("read_user_status,read_user_album,read_user_photo,status_update,read_user_feed,publish_feed,photo_upload");
         response.sendRedirect(Config.RR_OAUTH_URL+"?"+params);
	}

}
